<template>
  <div>
    <div id="myChart" ref="myChart" :style="{ width: '100%', height: '220px' }"></div>
  </div>
</template>
<script>
import echarts from "echarts";
export default {
  props: {
    formData: {},
    type: {},
    time: {
      type: String
    }
  },
  data() {
    return {};
  },
  watch: {
    formData: {
      handler(newVal, oldVal) {
        this.drawLine();
      },
      deep: true
    }
  },
  mounted() {
    this.drawLine();
  },
  methods: {
    drawLine() {
      var series = [
        {
          itemStyle: {
            normal: {
              color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                //   { offset: 0, color: "rgba(255,255,255,0)" },
                { offset: 0.5, color: "#58A55C" }
              ])
            }
          },
          data: this.formData.rgjtCount,
          type: 'bar',
          stack: 'a',
          barWidth: "15",
          name: '人工'
        },
        {
          itemStyle: {
            //
            normal: {
              color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                //   { offset: 0, color: "rgba(255,255,255,0)" },
                { offset: 0.5, color: "#68BBC4" }
              ])
            }
          },
          data: this.formData.jqrCount,
          type: 'bar',
          stack: 'a',
          name: '机器人'
        },
        {
          itemStyle: {
            //
            normal: {
              color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                //   { offset: 0, color: "rgba(255,255,255,0)" },
                { offset: 0.5, color: "#5087EC" }
              ])
            }
          },
          data: this.formData.ivrCount,
          type: 'bar',
          stack: 'a',
          name: 'IVR'
        }
      ];
      // 初始化echarts实例
      let myChart = this.$echarts.init(this.$refs.myChart);
      myChart.setOption({
        xAxis: {
          type: 'category',
    splitLine:{
         show:false // 不显示网格线
    },
          data: this.formData.date
        },
        yAxis: {
          type: 'value',
    splitLine:{
         show:false // 不显示网格线
    },
        },
        legend: {
      data: ['人工', '机器人', 'IVR'],
      show: true,
    },
        series: series
      });
    }
  }
};
</script>

<style scoped lang='less'>
.zhineng {
  background: #07cc94;
  width: 0.1rem;
  height: 0.1rem;
}

.zhuanren {
  background: #0095fd;
  width: 0.1rem;
  height: 0.1rem;
}

p {
  font-size: 0.1rem;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #3d3d3d;
  margin-left: 0.1rem;
  /* float: left; */
}
</style>
